home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig06_08.jar / Ch06 / Fig06_08 / Fig06_08.cpp next >
C/C++ Source or Header  |  1997-10-16  |  1KB  |  49 lines

  1. // Fig. 6.8: fig06_08.cpp 
  2. // Demonstrating a default constructor
  3. // function for class Time.
  4. #include <iostream.h>
  5. #include "time2.h"
  6.  
  7. int main()
  8. {
  9.    Time t1,             // all arguments defaulted
  10.         t2(2),          // minute and second defaulted
  11.         t3(21, 34),     // second defaulted 
  12.         t4(12, 25, 42), // all values specified
  13.         t5(27, 74, 99); // all bad values specified
  14.  
  15.    cout << "Constructed with:\n"
  16.         << "all arguments defaulted:\n   ";
  17.    t1.printMilitary();
  18.    cout << "\n   ";
  19.    t1.printStandard();
  20.  
  21.    cout << "\nhour specified; minute and second defaulted:" 
  22.         << "\n   ";
  23.    t2.printMilitary();
  24.    cout << "\n   ";
  25.    t2.printStandard();
  26.  
  27.    cout << "\nhour and minute specified; second defaulted:" 
  28.         << "\n   ";
  29.    t3.printMilitary();
  30.    cout << "\n   ";
  31.    t3.printStandard();
  32.  
  33.    cout << "\nhour, minute, and second specified:" 
  34.         << "\n   ";
  35.    t4.printMilitary();
  36.    cout << "\n   ";
  37.    t4.printStandard();
  38.  
  39.    cout << "\nall invalid values specified:" 
  40.         << "\n   ";
  41.    t5.printMilitary();
  42.    cout << "\n   ";
  43.    t5.printStandard();
  44.    cout << endl;
  45.  
  46.    return 0;
  47. }
  48.  
  49.